<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>联系 </title>
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <script src="../js/set-meta.js"></script>
  <link rel="stylesheet" type="text/css" href="../css/contact.css"/>
</head>

<body>
<script type="text/javascript"> 

//      var wsServer = 'ws://localhost:9999/webSocket.ashx'; //基于.NET4.5服务器地址  
        var wsServer = 'ws://192.168.123.17:8808'; //基于.NET服务器地址  
 
        var websocket = new WebSocket(wsServer); //创建WebSocket对象  
        //websocket.send("hello");//向服务器发送消息  
        //alert(websocket.readyState);//查看websocket当前状态  
        websocket.onopen = function (evt) {  
            //已经建立连接  
            alert("已经建立连接");  
        };  
        websocket.onclose = function (evt) {  
            //已经关闭连接  
            console.log("已经关闭连接");
        };  
        websocket.onmessage = function (evt) {  
            //收到服务器消息，使用evt.data提取  
            evt.stopPropagation()  
            evt.preventDefault()  
            //alert(evt.data);  
            writeToScreen(evt.data);  
            //websocket.close();  
        };  
        websocket.onerror = function (evt) {  
            //产生异常  
            //alert(evt.message);  
            writeToScreen(evt.message);
        };
        function sendMsg() {
            if (websocket.readyState == websocket.OPEN) {  
                msg = document.getElementById("msg").value;  
                websocket.send(msg);  
                writeToScreen("发送成功!");  
            } else {  
                writeToScreen("连接失败!");  
            }
        }
 
        function writeToScreen(message) {  
            var pre = document.createElement("p");  
            pre.style.wordWrap = "break-word";  
            pre.innerHTML += message;  
            output.appendChild(pre);  
        }  
        
        var playing = false, currentAudio = null;
				$(".audio").on("click", function () {
				    var $audio = $(this).find("audio");
				    if (playing) {
				        playing = false;
				        currentAudio.pause();
				        currentAudio.currentTime = 0;
				        currentAudio = null;
				    }
				    playing = true;
				    currentAudio = $audio.get(0);
				    currentAudio.play();
				});
    </script> 
		<header class="mui-bar-nav mui-bar-nav-1">
				<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
				<p class="mui-title mui-pull-left">联系</p>
				<a class="iconfont icon-shipin" id="toVideo"></a>
		</header>
		
		<div class="mui-content" >
				
		</div>
		 <div> 
        <input type="text" id="msg" value="beyond is number one!" /> 
        <button onclick="sendMsg()">send</button> 
    </div> 
    <div class="message-row">
    		<span class="icon"></span>
    		<div class="audio-part">
    				<span class="voice-icon"></span>
    				<span class="voice-time">50'25"</span>
    		</div>
    </div>
    <div class="message-row">
    		<span class="icon mui-pull-left"></span>
    		<div class="audio-part ">
    				<span class="voice-icon"></span>
    				<span class="voice-time">50'25"</span>
    		</div>
    </div>
    <div class="message-row message-row-self">
    		<span class="icon"></span>
    		<div class="audio-part">
    				<span class="voice-icon"></span>
    				<span class="voice-time">50'25"</span>
    		</div>
    </div>
    
    <div id="testBtn">
    	 语音
    </div>
    <div id="output"></div> 
		
<script src="../js/login.js"></script>

<script type="text/javascript">
		$('#testBtn').on('tap',function(){
			App.showPage('audio');
		});
		
		$('#toVideo').on('tap',function(){
			App.showPage('video');
		});
	
</script>
</body>

</html>